package com.manage.action;

import java.util.List;

import com.action.AbstractAction;
import com.manage.cache.ChannelAppInfoManager;
import com.manage.cache.ChannelManager;
import com.manage.cache.CpInfoManager;
import com.manage.cache.ProjectManager;
import com.manage.model.Channel;
import com.manage.model.ChannelAppInfo;
import com.manage.model.CpAppInfo;
import com.manage.model.CpInfo;
import com.manage.model.Project;
import com.manage.service.CpAppInfoService;
import com.manage.service.CpAppInfoServiceImpl;

public class AppQueryAction extends AbstractAction {

	private static final long serialVersionUID = 1L;
	public int cpId;
	public String appName;
	public int channelId;
	private List<CpInfo> cplist;
	private List<Channel> channellist;
	private String type;
	private String appnumber;
	private List<CpAppInfo> list;
	private List<ChannelAppInfo> calist;
	public String query()
	{
		cplist = CpInfoManager.getInstance().getCpInfos();
		channellist = ChannelManager.getInstance().getChannels();
		return SUCCESS;
	}
	public String data()
	{
		CpAppInfoService service = new CpAppInfoServiceImpl();
		list = service.getCpAppInfoByContent(cpId, channelId, appName);
//		if(channelId>0)
//		{
//			calist = ChannelAppInfoManager.getInstance().getChannelAppInfoByChannelId(channelId);
//		}else
//		{
//			calist = ChannelAppInfoManager.getInstance().getChannelAppInfos();
//		}
		return SUCCESS;
	}
	public String channelapp()
	{
		if(channelId>0)
		{
			calist = ChannelAppInfoManager.getInstance().getChannelAppInfoByAppNumberChannelId(channelId, appnumber);
		}else
		{
			calist = ChannelAppInfoManager.getInstance().getChannelAppInfoByAppNumber(appnumber);
		}
		return SUCCESS;
	}
	public String getcpname(int cpid)
	{
		CpInfo c = CpInfoManager.getInstance().getCpInfo(cpid);
		String str = "未知";
		if(c!=null)
			str = c.getShortName();
		return str;
	}
	public String channelName(int channelid,int projectid)
	{
		String str = "未知";
		Channel c = ChannelManager.getInstance().getChannel(channelid);
		if(c!=null)
		{
			Project p = ProjectManager.getInstance().getProject(projectid);
			str=c.getName();
			if(p!=null)
			{
				str+="-"+p.getName();
			}
		}
		return str;
	}
	public int getCpId() {
		return cpId;
	}
	public void setCpId(int cpId) {
		this.cpId = cpId;
	}
	public String getAppName() {
		return appName;
	}
	public void setAppName(String appName) {
		this.appName = appName;
	}
	public int getChannelId() {
		return channelId;
	}
	public void setChannelId(int channelId) {
		this.channelId = channelId;
	}
	public List<CpInfo> getCplist() {
		return cplist;
	}
	public void setCplist(List<CpInfo> cplist) {
		this.cplist = cplist;
	}
	public List<Channel> getChannellist() {
		return channellist;
	}
	public void setChannellist(List<Channel> channellist) {
		this.channellist = channellist;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public List<CpAppInfo> getList() {
		return list;
	}
	public void setList(List<CpAppInfo> list) {
		this.list = list;
	}
	public List<ChannelAppInfo> getCalist() {
		return calist;
	}
	public void setCalist(List<ChannelAppInfo> calist) {
		this.calist = calist;
	}
	public String getAppnumber() {
		return appnumber;
	}
	public void setAppnumber(String appnumber) {
		this.appnumber = appnumber;
	}
	
	
	
}
